<template>
  <div class="main">
    <NavbarComponent></NavbarComponent>
    <div class="content-wrapper">
      <div class="sidebar" style="display: contents;">
        <ul class="tabs">
          <li :class="{ active: activeTab === 'mine' }" @click="activeTab = 'mine'">
            <el-icon><User /></el-icon>我的
          </li>
          <li :class="{ active: activeTab === 'cart' }" @click="activeTab = 'cart'">
            <el-icon><ShoppingCart /></el-icon> 我的购物车
          </li>
          <li :class="{ active: activeTab === 'address' }" @click="activeTab = 'address'">
            <el-icon><MapLocation /></el-icon> 收货地址
          </li>
          <!-- <li :class="{ active: activeTab === 'footprint' }" @click="activeTab = 'footprint'">
            <el-icon><Clock /></el-icon>我的足迹
          </li> -->
          <li :class="{ active: activeTab === 'orders' }" @click="activeTab = 'orders'">
            <el-icon><Tickets /></el-icon> 我的订单
          </li>
        </ul>
      </div>
      <div class="main-content">
        <component :is="currentComponent"></component>
      </div>
    </div>
  </div>
</template>

<script>
import { defineComponent, ref, computed } from 'vue';
import NavbarComponent from '@/components/components/NavbarComponent.vue';
import Mine from '@/components/view/accountcenter/Mine.vue';
import Address from './Address.vue';
import Cart from './Cart.vue';
import FootPrint from './FootPrint.vue';
import Orders from './Orders.vue';
export default defineComponent({
  name: 'AccountCenter',
  components: {
    NavbarComponent,
    Mine,
    Address,
    Cart,
    FootPrint,
    Orders,
  },
  setup() {
    const activeTab = ref('mine'); // 默认选中“我的”标签

    const currentComponent = computed(() => {
      switch (activeTab.value) {
        case 'mine':
          return 'Mine';
        case 'cart':
          return 'Cart';
        case 'address':
          return 'Address';
        case 'footprint':
          return 'FootPrint';
        case 'orders':
          return 'Orders';
        default:
          return null;
      }
    });

    return {
      activeTab,
      currentComponent
    };
  }
});
</script>
<style scoped>
.content-wrapper {
  display: flex;
  height: 100vh;
  gap: 20px; /* 增加内容区域间隔 */
}

.sidebar {
  background-color: white;
  width: 260px;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  margin-left: 20px;
  margin-top: 20px;
  height: calc(100vh - 100px);
}

.tabs {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tabs li {
  padding: 16px 20px;
  cursor: pointer;
  font-size: 16px;
  border-radius: 8px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #606266;
  margin: 6px 0;
  position: relative;
}

/* 悬停效果 */
.tabs li:hover {
  background-color: #f5f7fa;
  transform: translateX(8px);
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.05);
}

/* 激活状态 */
.tabs li.active {
  background-color: #ecf5ff;
  color: #409eff;
  font-weight: 500;
}

/* 激活状态指示条 */
.tabs li.active::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 0;
  height: 100%;
  width: 4px;
  background-color: #409eff;
  border-radius: 2px;
}

/* 图标颜色跟随状态 */
.tabs li .el-icon {
  font-size: 18px;
}
.tabs li.active .el-icon {
  color: #409eff;
}

.main-content {
  padding: 20px;
  flex-grow: 1;
  background-color: white;
  border-radius: 12px;
  margin: 20px 20px 20px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
</style>